document.addEventListener('DOMContentLoaded', (event) => {

    let currentIndex = 0;


    const images = document.querySelectorAll('.carousel-img');


    const totalImages = images.length;


    function showImage(index) {


        images.forEach((img, i) => {


            img.classList.remove('active');


            if (i === index) {


                img.classList.add('active');


            }


        });


    }


    function nextImage() {


        currentIndex = (currentIndex + 1) % totalImages;


        showImage(currentIndex);


    }


    setInterval(nextImage, 3000); // 每3秒切换一次图片


    showImage(currentIndex);


});